summaryrefslogtreecommitdiff
path: root/src/pages/blog/micro/[page].astro
blob: 9fb04f1d63100bb25983de705e402a80e72c62dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
import MicroBlog from "@components/templates/MicroBlog.astro";
import Base from "@layouts/Base.astro";
import { fromPosts, isMicro } from "@lib/collection/helpers";
import { identity } from "@utils/anonymous";
import type {
  GetStaticPaths,
  InferGetStaticParamsType,
  InferGetStaticPropsType,
} from "astro";

export const getStaticPaths = (async ({ paginate }) => {
  const micros = await fromPosts(isMicro, identity);

  return paginate(micros, { pageSize: 20 });
}) satisfies GetStaticPaths;

export type Params = InferGetStaticParamsType<typeof getStaticPaths>;
export type Props = InferGetStaticPropsType<typeof getStaticPaths>;

const { page } = Astro.props;
---
<Base title="Micro Blogue">
  <h1>Page {page.currentPage}</h1>
  <ul>
    {page.data.map((micro) => <li><MicroBlog {...micro} /></li>)}
  </ul>
  {page.url.first ? <a href={page.url.first}>First</a> : null}
  {page.url.prev ? <a href={page.url.prev}>Previous</a> : null}
  {page.url.next ? <a href={page.url.next}>Next</a> : null}
  {page.url.last ? <a href={page.url.last}>Last</a> : null}
</Base>